<cfparam name="attributes.change_request_id">
<cfparam name="attributes.product_code">
<cfparam name="attributes.version" default="">

<cfquery name="check_product" datasource="#request.dsn#">
	exec asp_get_any_product_info_basic '#attributes.product_code#'
</cfquery>

<cfif check_product.recordcount>
	<cfset var.change_type = "chg_product">
<cfelse>
	<cfset var.change_type = "add_product">
</cfif>

<!--- Get all the available fields and corresponding values from the database --->
<cfquery name="get_fields" datasource="#request.dsn#">
	asp_Get_Change_Request_Element_XREF
		@iChange_Request_Id = #attributes.change_request_id#,
		@iSubmitted_By = '#session.TSR_CONTACT_ID#'
</cfquery>	

<cfsavecontent variable="var.fields" >
<cfoutput query="get_fields">

  <cfif len(get_fields.xsl_name) and find("0",get_fields.Not_In_Detail)><#lcase(get_fields.xsl_name)#>#trim(ucase(get_fields.ELEMENT_VALUE))#</#lcase(get_fields.xsl_name)#>#chr(13)#
  
  </cfif>
  
</cfoutput>
</cfsavecontent>


<cfscript>
	xml = 
	'
	<!DOCTYPE copy SYSTEM "#attributes.dtd#">
	<xtiinput>
	   <inputheader>
	      <actionset>
	         <action>#var.change_type#</action>
	      </actionset>
	   </inputheader>
	   <inputdata>
	      <product>
	         <product_code>#ucase(trim(attributes.product_code))#</product_code>
#var.fields#
	      </product>
	   </inputdata>
	 </xtiinput>';
</cfscript>

<!--- <cfdump var="#xml#"><cf_page_abort> --->